<?php
	$ssFilter = $this->arrParam['ssFilter'];
	$paginator = $this->arrParam['paginator'];
	$action_link = $this->baseUrl($this->currentController . '/filter/type/order');
	$iconPath = $this->baseUrl(PUBLIC_PATH . '/img/icon');

	$lblId = $this->cmsLinkSort('ID', 'id', $ssFilter, $iconPath, $action_link);
	$lblPositionId = $this->cmsLinkSort('Vị trí hiển thị', 'position_id', $ssFilter, $iconPath, $action_link);
	$lblPageId = $this->cmsLinkSort('Trang hiển thị', 'page_id', $ssFilter, $iconPath, $action_link);
	$lblPoint = $this->cmsLinkSort('Điểm', 'point', $ssFilter, $iconPath, $action_link);
	$lblNguoiCapNhat = $this->cmsLinkSort('Người cập nhật', 'nguoi_cap_nhat', $ssFilter, $iconPath, $action_link);
	$lblNgayCapNhat = $this->cmsLinkSort('Ngày cập nhật', 'ngay_cap_nhat', $ssFilter, $iconPath, $action_link);
	
	$keywords = $this->formText('keywords', $ssFilter['keywords'], array('class' => 'span3', 'placeholder' => 'Tìm kiếm', 'style' => 'margin-right:5px;'));

	$linkSearch = $this->baseUrl($this->currentController . '/filter/type/search/key/1');
	$btnSearch = $this->formButton('search-now', 'Search', array('onclick' => "OnSubmitForm('" . $linkSearch . "')",'class' => 'btn', 'style' => 'margin-right:5px;'));

	$linkResetSearch = $this->baseUrl($this->currentController . '/filter/type/search/key/0');
	$btnResetSearch = $this->formButton('clear-keywords', 'Clear', array('onclick' => "OnSubmitForm('" . $linkResetSearch . "')", 'class' => 'btn'));

	$strSearch = $keywords. ' ' . $btnSearch . ' ' . $btnResetSearch;
?>

<div id="toolbar-box" class="title">
	<div class="top-box">
		<div class="top-box">
			<div class="top-box"></div>
		</div>
	</div>
	<div class="m-box">
		<div class="icon-page title-users"></div>
		<div class="toolbar-button"></div>
		<div class="h2">Danh sách điểm</div>
		<div class="clear"></div>
	</div>
	<div class="bottom-box">
		<div class="bottom-box">
			<div class="bottom-box"></div>
		</div>
	</div>
</div>
<form name="appForm" action="" method="POST">
	<?php 
		if ($this->msg != '') {
			echo "<div class='alert alert-error' style='clear:both; margin-bottom: 5px;'>" . $this->msg . "</div>";
		}
	?>
	<!-- Search btn -->
	<p class="search-box input-append">
		<?php echo $strSearch; ?>
	</p>
	<div class="total-items">
		<!-- Total items label -->
		<span><?php echo $this->totalItems; ?> items</span>
	</div>
	<!-- Main grid  -->
	<table class="gridview">
		<thead>
			<tr class="success">
				<th><?php echo $lblPageId; ?></th>
				<th><?php echo $lblPositionId; ?></th>
				<th><?php echo $lblPoint; ?></th>
				<th width="130"><?php echo $lblNguoiCapNhat; ?></th>
				<th width="130"><?php echo $lblNgayCapNhat; ?></th>
			</tr>
		</thead>
		<tbody>
		<?php 
			$modal = '';

			if(count($this->Items) > 0) {
				foreach($this->Items as $key => $val) {
					$id    		   	= $val->getId();
					$position_id    = $val->getPosition_name();
					$page_id    	= $val->getPage_name();
					$point			= $val->getPoint();
					$ngay_cap_nhat 	= $val->getNgay_cap_nhat() != '' ? date("d-m-Y H:i:s", strtotime($val->getNgay_cap_nhat())) : $val->getNgay_cap_nhat();
					$nguoi_cap_nhat = $val->getTen_nguoi_cap_nhat();
					$modalLink	   	= 'pointModel' . $id;
					$linkEdit 	   	= $this->baseUrl($this->currentController . '/edit/id/' . $id . '/page/' . $paginator["currentPage"]);

					$action 	   	= '<div class="row-actions">
										<div class="btn-toolbar">
											<div class="btn-group">
		                           				<a class="btn btn-success btn-mini" href="' . $linkEdit . '"><i class="icon-pencil icon-white"></i>Sửa</a>
                               		  </div></div></div>';

					echo '<tr>';
					echo '<td class="first"><strong><a role="button" data-toggle="modal" href="#' .$modalLink . '">' . $page_id . '</a></strong>' . $action . '</td>';
					echo '<td>' . $position_id . '</td>';
					echo '<td>' . $point . '</td>';
					echo '<td>' . $nguoi_cap_nhat . '</td>';
					echo '<td>' . $ngay_cap_nhat . '</td>';
					echo '</tr>';
				}
			} else {
		?>
				<tr><td colspan="6" align="center">Không có dữ liệu.</td></tr>
		<?php
			}
		?>
		</tbody>
		<!-- BEGIN: PAGINATION (FOOT) -->
		<tfoot>
			<tr>
				<td colspan="8">
					<div class="container">
						<div class="pagination">
							<?php
								$currentUrl = $this->baseUrl($this->currentController . '/index');
								echo $this->paginationControl($this->panigator, 'Sliding', 'pagination.phtml', array('currentUrl' => $currentUrl));
							?>
						</div>
					</div>
				</td>
			</tr>
		</tfoot>
		<!-- END: PAGINATION (FOOT) -->
	</table>
</form>